﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace PTiRouZ.Net.SilverLight.Api.HelloTipi
{
    public delegate void EndSessionEventHandler(object sender, EndSessionEventArgs e);

    public class EndSessionEventArgs : EventArgs
    {
    }

    public partial class apitxt : api
    {

        public event EndSessionEventHandler EndSessionCompleted;

        /// <summary>Permet de se deconnecter ad service.</summary>
        /// <example>http://apitxt.hellotipi.com/account/end_session.json</example>
        public void end_session()
        {
            base.APICallCompleted += new APICallCompletedEventHandler(EndSessionCallCompleted);
            PostUrlApi("account/end_session");
        }

        void EndSessionCallCompleted(object sender, ApiOpenReadCompletedEventArgs e)
        {
            try
            {
                EndSessionCompleted.Invoke(sender, new EndSessionEventArgs());
            }
            finally
            {
                base.APICallCompleted -= new APICallCompletedEventHandler(EndSessionCallCompleted);
            }
        }

    }
}
